<template>
  <div class="account">
    <div class="account-item">
      <div class="account-item-flex">
        <div class="flex-l">
          <img src="@/assets/home/sock-icon.png" class="img" />
          <div class="info">
            <h3 class="title">登录密码</h3>
            <p class="desc">用于登录系统和保护账号信息</p>
          </div>
        </div>
        <div class="flex-r" @click="handleUpdate(1)">修改</div>
      </div>
    </div>
    <div class="account-item">
      <div class="account-item-flex">
        <div class="flex-l">
          <img src="@/assets/home/phone-icon.png" class="img" />
          <div class="info">
            <h3 class="title">安全手机 {{(userInfo.mobile||'').replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2")}}</h3>
            <p class="desc">用于登录系统和保护账号信息</p>
          </div>
        </div>
        <div class="flex-r" @click="handleUpdate(2)">修改</div>
      </div>
    </div>
    <!-- <model v-if="isModel" :type="type" @model="handleClose" /> -->
  </div>
</template>
<script>
import { mapState, mapMutations } from "vuex";
import mTypes from "@/store/mutationsTypes";
import model from './model.vue'
export default {
  name: 'account',
  components: {
    model
  },
  computed: {
    ...mapState({
      userInfo: state => state.userInfo
    })
  },
  data () {
    return {
      isModel: false,
      type: 1 // 1 密码  2 手机
    }
  },
  methods: {
    handleUpdate (type) {
      let obj = {
        type,
        isModel: true
      }
      this.$emit('changeSafe', obj)
      // this.type = type
      // this.isModel = true
    },
    handleClose (val) {
      this.isModel = val
    }
  }
}
</script>
<style lang="less" scoped>
.account {
  display: flex;
  margin-top: 20px;
  &-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 490px;
    height: 150px;
    background: #fff;
    border: 1px solid #EAEAEA;
    border-radius: 10px;
    &:last-child {
      margin-left: 20px;
    }
    &-flex {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;
      .flex-l {
        display: flex;
        align-items: center;
        margin-left: 40px;
        .img {
          width: 40px;
          height: 40px;
          margin-right: 20px;
        }
        .title {
          font-size: 20px;
          font-family: Microsoft YaHei;
          font-weight: bold;
          line-height: 20px;
          color: #333333;
        }
        .desc {
          font-size: 16px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          line-height: 18px;
          color: #BCBCBC;
          margin-top: 10px;
        }
      }
      .flex-r {
        width: 80px;
        height: 36px;
        line-height: 36px;
        text-align: center;
        font-size: 14px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #FFFFFF;
        background: #27BFA3;
        border-radius: 18px;
        margin-right: 20px;
        cursor: pointer;
      }
    }
  }
}
</style>
